<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@page import="java.util.Calendar"%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>业主欠费汇总查询</title>
<LINK href="images/css.css" type="text/css" rel="stylesheet">
<script language="javascript">
	var req;
	
	function init() {
		if (window.XMLHttpRequest) {
			req = new XMLHttpRequest();
		} else if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	
	//根据物业服务处ID查询DropChangeAJAXAction，获得该物业服务处的小区列表
	function changeDropOfSub() {
		init();
		
		var url="dropChangeAJAX.do?method=changeDropOfSub&distId="+escape(document.forms[0].distId.options[document.forms[0].distId.selectedIndex].value);
		
		req.open("get", url, true);
		req.onreadystatechange = callback;
		req.send(null);
	}
	function callback() {
		if (4 == req.readyState) {
			if (200 == req.status) {
				eval(req.responseText);
			}
		}
	}
	function setup(a){
		init();
		var url="dropChangeAJAX.do?method=changeDropOfSub&distId="+escape(a)
		req.open("get", url, true);
		req.onreadystatechange = callback;
		req.send(null);
	}
	function checkForm() {
		var distId = document.forms[0].distId.value;
		var subId = document.forms[0].subId.value;
		if(distId!=0&&subId==0) {
			alert("请选择小区");
			return false;
		}
		return true;
	}

</script>

</head>
<body>
<html:form action="queryOweCollectCharge.do?method=unspecified" method="post" onsubmit="return checkForm();">
<table align="center" width="60%" border="0">
	<tr>
		<td class="STYLE4" align="center" bgcolor="#ffffff" colspan="2"
			height="40">业主欠费汇总查询</td>
	</tr>
	<tr><td><table align="center" class="tableline" cellspacing="1" cellpadding="0" width="100%" border="0">
     <c:if test="${user.nickname eq '管理员'}">
    <tr>
		<td width="30%" height="26" align="right" bgcolor="#ffffff">
		物业服务处：</td>
		
		<td width="70%" bgcolor="#ffffff">
			&nbsp;<html:select property="distId" onchange="changeDropOfSub()" style="width:120px">
					<html:option value="0">请选择</html:option>
						<c:if test="${!empty distList}">
							<c:forEach items="${distList}" var="dist">
								<html:option value="${dist.id}">${dist.name}</html:option>
							</c:forEach>
						</c:if>
					</html:select><span id="noticeSpan" style="color:#5f9c12;">&nbsp;&nbsp;如果不选择物业服务处，则查询所有小区当月业主缴费汇总！</span>
		</td>
		
	</tr>
	</c:if>
	<c:if test="${user.nickname ne '管理员'}">
	 <tr>
		<td width="30%" height="26" align="right" bgcolor="#ffffff">
		物业服务处：</td>
		
		<td width="70%" bgcolor="#ffffff">
			&nbsp;<html:select property="distId" onchange="changeDropOfSub()" style="width:120px">
						<c:if test="${!empty distList}">
							<c:forEach items="${distList}" var="dist">
							<c:if test="${user.district.id == dist.id }">
								<html:option value="${dist.id}">${dist.name}</html:option>
								</c:if>
							</c:forEach>
						</c:if>
					</html:select><span id="noticeSpan" style="color:#5f9c12;">&nbsp;&nbsp;请选择小区，查询小区当月业主缴费汇总！</span>
		</td>
		
	</tr>
	<script language="javascript">changeDropOfSub();</script>;
	</c:if>
	<tr>
		<td width="30%" height="26" align="right" bgcolor="#ffffff">小区：</td>
		<td width="70%" bgcolor="#ffffff">
		&nbsp;<html:select property="subId" style="width:120px">
				<html:option value="0">请选择</html:option>
			</html:select>
		</td>	
	</tr>
	<tr>
	  <td width = "30%" height = "26" align = "right" bgcolor = "#ffffff">欠费年月：</td>
	  <td width = "70%" bgcolor = "#ffffff">
	  	<%
	  		int thisYear=Calendar.getInstance().get(Calendar.YEAR);
	  		int thisMonth=Calendar.getInstance().get(Calendar.MONTH)+1;
	  	%>
	    &nbsp;<html:select property="year" style="width:60px;">
	    	<%for(int i=thisYear;i>thisYear-10;i--){ %>
	    		<html:option value="<%=String.valueOf(i) %>"><%=i%></html:option>
	    	<%} %>
	   	</html:select>
		<select name="month" style="width:55px;">
			<%for(int j=1;j<=12;j++){ %>
	    		<option value="<%=String.valueOf(j) %>" <%if(j==thisMonth){out.print("selected='selected'");} %>><%=j%></option>
	    	<%} %>
	   	</select>	
	   	&nbsp;&nbsp;<html:submit value="查询详情"/>   	
	  </td>
	</tr>
	</table>
  </td></tr>
</table>
</html:form>
</body>
</html>